package lt.vu.mif.os.memory;

import lt.vu.mif.os.RealMachine;
import lt.vu.mif.os.provider.Constants;
/**
* User memory
* @author Antanas Rudaitis
* @author Laurynas Paradauskas
* @author Algirdas Šaltupis
* 
*/
public class UserMemory implements Constants {
    private static int startedApps = 0;
    public static Word[] memory = new Word[userMemSize];

    public static void init() {
      for (int i=0; i<memory.length; i++)
        memory[i] = new Word();
      resetToZero();
    }

    public static Word[] getMemory() {
      Word[] memForApp = new Word[vmMemSize];
      for (int i=0; i<vmMemSize; i++) 
        memForApp[i] = memory[Constants.blockSize*(RealMachine.getVMCounter()-1)+i];
      //startedApps++;
      return memForApp;
    }
    public static void resetToZero() {
        for (int i=0; i<userMemSize; i++)
            memory[i].set("    ");
    }

    public static void setValue(int index, Word word) {
      memory[index] = word;
    }

    public static Word getWord(int index) {
      return memory[index];
    }
}